package com.zxy.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Zxy
 * @Date: 2021-06-11
 **/
@RestController
public class DemoController {

    @GetMapping("/demo")
    // 熔断之后的快速处理，当作一个备选方案
    // @HystrixCommand(fallbackMethod = "demoFallBackMethod")
    public String demo(Integer id) {
        System.out.println("demo ok");
        if (id < 0) {
            throw new RuntimeException("无效id");
        }
        return "demo ok";
    }

    public String demoFallBackMethod(Integer id){
        return "当前活动过于火爆，服务被熔断";
    }
}
